package com.css.fxfzysx.modules.vaolEngineering.controller;

import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.modules.vaolEngineering.entity.CpVulnerabilityEntity;
import com.css.fxfzysx.modules.vaolEngineering.service.PseVulnerabilityService;
import com.css.fxfzysx.modules.vaolEngineering.vo.PseVulnerabilityVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 供电设备
 */
@RestController
@RequestMapping("pseVulnerability")
@Slf4j
public class PseVulnerabilityController {

    @Autowired
    private PseVulnerabilityService pseVulnerabilityService;

    /**
     * 供电设备保存
     * @return
     */
    @PostMapping("savePseVulnerability")
    public RestResponse savePseVulnerability(@RequestBody PseVulnerabilityVo pseVulnerabilityVo){
        try {
            pseVulnerabilityService.savePseVulnerability(pseVulnerabilityVo.getCpVulnerabilityList(),pseVulnerabilityVo.getTableParam());
            return RestResponse.succeed("保存成功!");
        } catch (Exception e) {
            log.error("post savePseVulnerability error:{}",e.getMessage(),e);
            return RestResponse.fail("保存失败!");
        }
    }

    /**
     * 供电设备计算
     */
    @PostMapping("caPseVulnerability")
    public RestResponse caPseVulnerability(@RequestBody List<CpVulnerabilityEntity> cpVulnerabilityList){
        return pseVulnerabilityService.caPseVulnerability(cpVulnerabilityList);
    }

    /**
     * 供电设备曲线
     */
    @GetMapping("generateCurve")
    public RestResponse generateCurve(String projectId){
        return pseVulnerabilityService.generateCurve(projectId);
    }
}
